package com.example.john.ksoap2test001;

import android.os.Handler;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {
    private ListView lv;

    private List<String> ll=new ArrayList<String>();

    private  List<Food> foods=new ArrayList<Food>();
    private  void initData(){
        int[] ii=new int[]{R.drawable.a24,R.drawable.a9};
        for(int i=0;i<2;i++){
            Food f=new Food();
            f.setTitle("Title.."+i);
            f.setContent("contetn....." + i);
            f.setSnap(ii[i]);
            foods.add(f);
        }
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initData();
        MyAdapter adapter=new MyAdapter(foods,getLayoutInflater());

        lv=(ListView)findViewById(R.id.lv);
        lv.setAdapter(adapter);
        lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                TextView tv=(TextView)view;
                Log.i("john",tv.getText().toString());
            }
        });


    }
    public void getPro(View view) {


    }


}
